<?php

namespace App\Admin\Extensions;

use Encore\Admin\Admin;

class Payquery
{
    public function __construct($oid, $name)
    {
        $this->oid = $oid;
        $this->name = $name;
    }
    protected function script()
    {
        return <<<SCRIPT

layui.use('layer', function(){
        var layer = layui.layer;
        
        $('.payquery').click(function () {
           var that = this;
            var orderid = $(that).attr('data-id');
            var user_name = $(that).attr('data-name');
           
            var index = layer.open({
                content: '/admin/zhifu/payquery?oid='+orderid,
                type: 2,
                title: '<\span style="color:red">'+user_name+'</\span>',
                area: ['70%', '30%'],
                btn: ['取消'],
            });         
       });
});

SCRIPT;
    }

    protected function render()
    {
        Admin::script($this->script());
        return "&nbsp;<a href='javascript:void(0);'><button data-id='{$this->oid}' data-name='{$this->name}' class='payquery layui-btn layui-btn-xs' style='color: #fff !important;background-color: #5FB878 !important;'>打款查询</button></a>";
    }

    public function __toString()
    {
        return $this->render();
    }
}